package com.bjsxt;

import java.util.Objects;

public class Babys {
    private String name;
    private int weight;
    //构造法
    public Babys(String name, int weight) {
        this.name = name;
        this.weight = weight;
    }

    public Babys() {
    }

    //get set 方法
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getWeight() {
        return weight;
    }

    public void setWeight(int weight) {
        this.weight = weight;
    }
    //重写toString

    @Override
    public String toString() {
        return "Babys{" +
                "name='" + name + '\'' +
                ", weight=" + weight +
                '}';
    }
    //从写hashcode与equal()

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Babys babys = (Babys) o;
        return weight == babys.weight && Objects.equals(name, babys.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, weight);
    }
}
